<? 
session_start();
if(!session_is_registered(uid)){
    echo "You have to login to view this page!</br></br>";
    echo "Click here to return to the "; 
    echo '<a href="./../index.php" title="Login">Login Page</a></br></br>';
    echo "Or sign up using this link ";
    echo '<a href="./../Registration/registration.html" title="Registration">Registration Page</a>';
exit();
}
else 
//Add tank form option
    include 'tank.html';

    
    //Manual SQL Connection
    $con = mysql_connect("localhost", "root", "root") or die ( "Error connectiong to DB: ".mysql_error());
       
    mysql_select_db("reeferslog", $con) or die ( "Error selecting specific DB, reefeerslog: ".mysql_error());
    
    //Variables
    $tanktype = $_POST['tanktype'];
    $size = $_POST['size'];
    $manufacturer = $_POST['manufacturer'];
    //$date = $_POST['date'];
    $cost = $_POST['cost'];
    
    //Date variables
    $day = $_POST['day'];
    $month = $_POST['month'];
    $year = $_POST['year'];
    
    //Function to make a valid date input
    $date = $year."-".$month."-".$day;
      
    //SQL Query to add tank info
    $add_tank = "insert into tank (user_id,tank_size,tank_type,manufacturer,date_setup,cost) values ('". $_SESSION['uid'] ."','$size','$tanktype','$manufacturer','$date','$cost')";

        //Execute Insert command
        if (!mysql_query($add_tank,$con))
            {
              die('Error: ' . mysql_error());
            }
            echo "Tank added successfully!"; 
               
    //Close SQL input
    mysql_close($con);
?>